﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.View.SprintPlanningTask"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    xmlns:local="clr-namespace:ScrumTable.UI.View.WinTouch.Util"
    xmlns:loc="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View"                               
    xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:CustomControl1="clr-namespace:ScrumTable.UI.View.WinTouch.CustomControl" xmlns:ShaderEffectLibrary="clr-namespace:ShaderEffectLibrary;assembly=ScrumTable.UI.View"
                               xmlns:Tool="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.Tool"
                               xmlns:Tools="clr-namespace:ScrumTable.UI.ViewModel.Tools;assembly=ScrumTable.UI.ViewModel"
                               xmlns:SubControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.SubControls"
                               xmlns:Command="clr-namespace:ScrumTable.UI.View.Command;assembly=ScrumTable.UI.View"
                               Foreground="White"  HorizontalAlignment="Stretch" Background="White"
    x:Name="ControlRoot">

    <UserControls:ScrumUserControl.CommandBindings>
        <CommandBinding 
          Command="{x:Static Command:CommandLib.SelectVelocityItem}"          
          Executed="OnVelocityClick"/>

    </UserControls:ScrumUserControl.CommandBindings>

    
    <UserControls:ScrumUserControl.Resources>
        <Converter:ConverterIsNullVisibility x:Key="ConverterIsNullVisibility"/>
        <Converter:ConverterIsNullVisibility  x:Key="ConverterIsNotNullVisibility" Invert="True"/>
        <Converter:ConverterBoolVisibility x:Key="ConverterBoolVisibility"/>
        <Converter:ConverterNotBoolVisibility x:Key="ConverterNotBoolVisibility"/>
        <Converter:OpacitymaskConverter x:Key="ConverterOpacityMask"/>
        <Converter:CalcConverter CalcType="Add" ValueRight="75" x:Key="AddMargin"/>

        <Style TargetType="{x:Type s:SurfaceButton}" BasedOn="{local:MultiStyle StyleFeedbackButton DescriptionButton}" x:Key="SelectorButton">
            <Style.Setters>
                <Setter Property="Margin" Value="5"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="Padding" Value="0"/>
                <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/>
            </Style.Setters>
        </Style>

        
            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5" x:Key="FadeOpacityMask">
                <GradientStop Color="#33000000" Offset="1"/>
                <GradientStop Color="#33000000"/>
            </LinearGradientBrush>

        <DataTemplate x:Key="listTemplate">
            <TextBlock HorizontalAlignment="Center" Foreground="Gray" Style="{StaticResource DescriptionTextBlock}" MinWidth="40">
                <TextBlock.Text>
                    <Binding Path="Name" />
                </TextBlock.Text>
            </TextBlock>
        </DataTemplate>
        
    </UserControls:ScrumUserControl.Resources>

    <Grid Margin="20,20,20,20">                
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{Binding ConfigManager.Config.ControlSize.X, ElementName=ControlRoot, Converter={StaticResource AddMargin}}"/>
            <ColumnDefinition Width="{Binding ConfigManager.Config.ControlSize.X, ElementName=ControlRoot, Converter={StaticResource AddMargin}}"/>
            <ColumnDefinition/>                     
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="220"/>            
        </Grid.RowDefinitions>


        
        <!--
        <Label Grid.Row="0" Grid.Column="1" Content="{loc:Translate Uid=General_SprintBacklog, Default=[SprintBacklog]}" Style="{StaticResource DescriptionLabel}"/>
         -->
        <Grid  Grid.Row="0" Grid.Column="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>            
            <Label Grid.Row="0" Grid.Column="0" Content="{loc:Translate Uid=General_SprintBacklog, Default=[SprintBacklog]}" Style="{StaticResource DescriptionLabel}"/>
            <ComboBox Background="Transparent" ItemsSource="{Binding Path=ScrumData.CurrentProject.Iterations}" IsTabStop="False" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" BorderBrush="Transparent" Margin="0" Grid.Column="2" ItemTemplate="{StaticResource listTemplate}"  MinWidth="60" SelectedItem="{Binding SelectedIteration}" />
        </Grid>
        
        <Label Grid.Row="0" Grid.Column="0" Content="{loc:Translate Uid=General_ProductBacklog, Default=[ProductBacklog]}" Style="{StaticResource DescriptionLabel}"/>
        <StackPanel  Grid.Row="0" Grid.Column="2" Orientation="Horizontal" Margin="20,0,0,0">
            <Label Content="{loc:Translate Uid=SprintPlanningTask_SelectedItem, Default=[SelectedItem]}" Style="{StaticResource DescriptionLabel}" Padding="0" Margin="0" Visibility="{Binding SelectedUserStory, Converter={StaticResource ConverterIsNullVisibility}}"/>
            <Label Content="{loc:Translate Uid=SprintPlanningTask_NoSelectedItem, Default=[NoSelectedItem]}" Style="{StaticResource DescriptionLabel}" Padding="0" Margin="0" Visibility="{Binding SelectedUserStory, Converter={StaticResource ConverterIsNotNullVisibility}}"/>
            <Label Content=" " Style="{StaticResource DescriptionLabel}" Padding="0" Margin="0"/>
            <Label Style="{StaticResource DescriptionLabel}" Padding="0" Margin="0">
                <TextBlock Text="{Binding SelectedUserStory.BackEndId, StringFormat=( #{0} )}"/>
            </Label>
            <Label Content=" " Style="{StaticResource DescriptionLabel}" Padding="0" Margin="0"/>
            <Label Content="{Binding SelectedUserStory.Name}" Style="{StaticResource DescriptionLabel}" Padding="0" Margin="0"/>
        </StackPanel>
        

        <UserControls:SurfaceDragDropListBox  Grid.Row="1" Grid.Column="0"
            x:Name="StoriesOpenList" BorderThickness="0" 
            AllowDrop="True" IsItemSelectable="True" SelectedItem="{Binding SelectedUserStoryProject, Mode=TwoWay}" 
            ItemsSource="{Binding Path=StoriesOpen}"        
            s:SurfaceDragDrop.Drop="OnOpenStoriesDrop" 
            Background="Transparent" 
            ShowSelection="False"
            HorizontalContentAlignment="Center">
            <UserControls:SurfaceDragDropListBox.ItemTemplate>
                <DataTemplate>
                    <UserControls:ScrumItemControl DataContext="{Binding}" Style="{StaticResource ScrumItemControlSelection}"/>
                </DataTemplate>
            </UserControls:SurfaceDragDropListBox.ItemTemplate>
        </UserControls:SurfaceDragDropListBox>

        <UserControls:SurfaceDragDropListBox  Grid.Row="1" Grid.Column="1" ItemsAreStatic="True"
            x:Name="StoriesIterationList"  BorderThickness="0" 
            AllowDrop="True"
            ItemsSource="{Binding Path=StoriesIteration}"
            SelectedItem="{Binding Path=SelectedUserStoryIteration, Mode=TwoWay}" 
            s:SurfaceDragDrop.Drop="OnIterationDrop"
            Background="Transparent"
            ShowSelection="False"
            HorizontalContentAlignment="Center">
            <UserControls:SurfaceDragDropListBox.ItemTemplate>
                <DataTemplate>
                    <UserControls:ScrumItemControl DataContext="{Binding}" Style="{StaticResource ScrumItemControlSelection}"/>
                </DataTemplate>
            </UserControls:SurfaceDragDropListBox.ItemTemplate>
        </UserControls:SurfaceDragDropListBox>
        

        <Grid Grid.Row="1" Grid.Column="2" Grid.RowSpan="4" Margin="20,0,0,0">
            <Grid.Style>
                <Style TargetType="{x:Type Grid}">
                    <Setter Property="IsEnabled" Value="True"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding DataContext.SelectedUserStory, ElementName=ControlRoot}" Value="{x:Null}">
                            <Setter Property="IsEnabled" Value="False"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>
            <UserControls:UserStoryControlBackFullSize DataContext="{Binding SelectedUserStory}">
                <UserControls:UserStoryControlBackFullSize.Style>
                    <Style TargetType="{x:Type UserControls:UserStoryControlBackFullSize}">
                        <Setter Property="OpacityMask" Value="{x:Null}"/>                        
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding DataContext.SelectedUserStory, ElementName=ControlRoot}" Value="{x:Null}">
                                <Setter Property="OpacityMask" Value="{StaticResource FadeOpacityMask}"/>                                
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </UserControls:UserStoryControlBackFullSize.Style>                
            </UserControls:UserStoryControlBackFullSize>
        </Grid>


        <StackPanel Orientation="Horizontal"  Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,20,0,0">
            <s:SurfaceButton Content="{loc:Translate Uid=General_Member, Default=[Members]}" Click="OnShowMemberClick">
                <s:SurfaceButton.Style>                    
                    <Style TargetType="{x:Type s:SurfaceButton}" BasedOn="{StaticResource SelectorButton}">
                        <Setter Property="FontWeight" Value="Normal"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsMemberShow}" Value="True">
                                <Setter Property="FontWeight" Value="Bold"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </s:SurfaceButton.Style>
            </s:SurfaceButton>            
            <Rectangle VerticalAlignment = "Top" Width = "1"  Fill="Black" Height="15" Margin="10,10,10,10"/>
            <s:SurfaceButton Content="{loc:Translate Uid=General_Velocity, Default=[Velocity]}" Click="OnShowSprintClick">
                <s:SurfaceButton.Style>
                    <Style TargetType="{x:Type s:SurfaceButton}" BasedOn="{StaticResource SelectorButton}">
                        <Setter Property="FontWeight" Value="Normal"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsMemberShow}" Value="False">
                                <Setter Property="FontWeight" Value="Bold"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </s:SurfaceButton.Style>
            </s:SurfaceButton>
        </StackPanel>

        <Border Name="Border2"  Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"  Visibility="{Binding DataContext.IsMemberShow, Converter={StaticResource ConverterBoolVisibility}, ElementName=ControlRoot }">        
            <Tool:TeamMemberSelector ScrollViewer.VerticalScrollBarVisibility="Visible" >
                <UserControls:ScrumUserControl.BuildUpViewModelSource>
                    <Tools:ViewModelTeamSelector/>
                </UserControls:ScrumUserControl.BuildUpViewModelSource>
            </Tool:TeamMemberSelector>
        </Border>


        <Border Name="Border" Margin="0,-8,0,0"  Grid.Column="0" Grid.ColumnSpan="2" Padding="0"  Grid.Row="3" BorderThickness="0" Visibility="{Binding IsMemberShow, Converter={StaticResource ConverterNotBoolVisibility} }" Panel.ZIndex="-9999">
            <s:SurfaceScrollViewer  x:Name="ScrollViewListVelocity" Padding="0,0,0,0" Margin="3" VerticalScrollBarVisibility="Visible" Elasticity="0,0" IsDeferredScrollingEnabled="False"  AllowDrop="True"  >
                <SubControls:VelocityChart DataContext="{Binding Velocity}" AllowDrop="True"/>
            </s:SurfaceScrollViewer>
        </Border>
    </Grid>
</UserControls:ScrumUserControl>
